<cfparam name="dir" default="/">

<cfcookie name="dir" value="#dir#" expires="1">

<cfif isdefined('url.imagefile')>
    <cfcookie name="orig_imagefile" expires="NEVER" value="#url.imagefile#">
    <!---clear temp directory--->
    <cfif directoryexists('#request.basepath#images/temp')>
	    <cfdirectory action="delete" directory="#request.basepath#images/temp" recurse="yes">
    </cfif>
    <cfdirectory action="create" directory="#request.basepath#images/temp">
	<!---copy the image to edit to the temp folder so we can save changes--->
    <cffile action = "copy" source = "#request.basepath#images#dir##url.imagefile#" destination="#request.basepath#images/temp/1_#url.imagefile#" nameconflict="overwrite" mode="777">
	<cfcookie name="imagefile" value="1_#url.imagefile#">
	<cfcookie name = "current_step" value="1">
</cfif>

<cfif cookie.current_step GT 1>
	<cfset undo_enabled = 1>
<cfelse>
	<cfset undo_enabled = 0>
</cfif>

<form action="index.cfm?c=imageeditor&a=crop" method="post" id="cropform">
<input type="hidden" id="x" name="x" />
<input type="hidden" id="y" name="y" />
<input type="hidden" id="w" name="w" />
<input type="hidden" id="h" name="h" />
</form>

<!---top menu--->
<cfinclude template="../dsp/menu.cfm">
<div id="image_editor" style="background: #FFFFFF;">
	<cfoutput><img id="image_editing" style="background: ##FFFFFF; max-width: 100%;" src="#request.homeurl#images/temp/#cookie.imagefile#" border="1" title="image not found" /></cfoutput>
</div>
<div id="dialog" style="display: none; font-size: 10pt;">
<img src="/images/defaults/loading.gif" />
</div>
<div id="defaultdialog" style="display: none;">
<img src="/images/defaults/loading.gif" />
</div>